<%@ page language="java" isELIgnored="false" import="java.util.*"
	pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<%@ taglib prefix='security' uri='http://www.springframework.org/security/tags' %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/css/style_new.css"/>
<script type="text/javascript" src="<%=request.getContextPath() %>/jsFile/js_new/nav.js"></script>
<script type="text/javascript">
$(function() {
  var tree = $("#yuyunav");
	var urls="<%=request.getContextPath() %>"+"/auth/Menu/findAllMenuByUser.koala";
	 $.ajax({
			url:urls,
			type : "POST",
			cache : false, 
			async : true,
		    dataType:'json',
		    success:function(data){
		   	
		   	$.each(data.data,function(idx,e){
	    		var li='';
	    		if("首页" == e.name){
	    			tree.append('<li ><a href="javascript:void(0)" style="cursor:pointer" onclick=gogogo("'+e.children[0].identifier+'?code='+e.desc+'")>'+e.name+'</a></li>');
	    		}else{
	    			$.each(e.children, function(i,menu){
	    				var url =menu.identifier;
	    				 if(/=/.test(url)){
		   					 url=url+'&code='+menu.desc;
		   				 }else{
		   					 url=url+'?code='+menu.desc;
		   				 }
	    				 li += '<li><a onclick=gogogo("'+url+'") style="cursor:pointer">'+menu.name+'</a></li>';
	    			});
	    			 tree.append('<li ><a href="#" style="cursor:pointer">'+e.name+'</a><ul>'+li+'</ul></li>');
	    		}
	    		
	    	}); 
		   	/* 	var obj = eval('(' + data + ')');
		   		$.each( obj, function(idx, e){
		   			$.each( e.head, function(id, ex){
		   				var li='';
		   				$.each( ex.menus, function(id, menu){
		   					
		   					 var url=menu.url;
			   				 if(/=/.test(url)){
			   					 url=url+'&code='+menu.code;
			   				 }else{
			   					 url=url+'?code='+menu.code;
			   				 }
		   					li += '<li><a onclick=gogogo("'+url+'") style="cursor:pointer">'+menu.menuname+'</a></li>';
		   				});
		   				if(ex.menuname=="首页"){
		   				 	tree.append('<li ><a href="javascript:void(0)" style="cursor:pointer" onclick=gogogo("'+ex.menus[0].url+'?code='+ex.code+'")>'+ex.menuname+'</a></li>');
		   				 }else{
		   					 tree.append('<li ><a href="#" style="cursor:pointer">'+ex.menuname+'</a><ul>'+li+'</ul></li>');
		   			 	}
		   			});
		   		}); */
		    },
		    error:function(){ 
		    	alert("请先登录");
		    },
	 });
 /*  for (var name in _menus){
		 var title = _menus[name][0];
		 var li = '';
		 var count = title.menus.length;
		 for(var i = 0; i < count; i++){
			 var url =title.menus[i].url;
			 if(/=/.test(url)){
				 url=url+'&code='+title.menus[i].code;
			 }else{
				 url=url+'?code='+title.menus[i].code;
			 }
			 li += '<li><a onclick=gogogo("'+url+'") style="cursor:pointer">'+title.menus[i].menuname+'</a></li>';
		 }	
		 if(title.menuname=="首页"){
			 tree.append('<li ><a href="javascript:void(0)" style="cursor:pointer" onclick=gogogo("'+title.menus[0].url+'?code='+title.menus[0].code+'")>'+title.menuname+'</a></li>');
		 }else{
			 tree.append('<li ><a href="#" style="cursor:pointer">'+title.menuname+'</a><ul>'+li+'</ul></li>');
		 }
	} */
  
  $("#currentDate").text(currentDate());
  
})

function gogogo(url){
	location.href = url.indexOf("/")==0 ? '<%=request.getContextPath() %>'+url : '<%=request.getContextPath() %>/'+url;
}

function currentDate(){ 
    var now = new Date();       
    var year = now.getFullYear();
    var month = now.getMonth() + 1;
    var day = now.getDate();
   
    var today = year + "-";       
    if(month < 10)
        today += "0";       
    today += month + "-";       
    if(day < 10)
        today += "0";           
    today += day;       
    return(today); 
} 

</script>
<div class="top_banner">
	<div class="main_max">
	  <div class="logo_tt"></div>
	  <div class="welcome_bgs"><s:text name="treelist.todatyIs"/><span id="currentDate"style="width: 70px;"/></span>&nbsp;&nbsp;<security:authentication property="principal.username" />，<s:text name="treelist.hi"/>！</div>
	  <div class="quite"><a href="http://www.foreveross.com" target="_blank"><s:text name="treelist.aboutUs"></s:text></a>   <a href="http://www.foreveross.com" target="_blank"><s:text name="treelist.help"></s:text></a>     <a href="<%=request.getContextPath() %>/j_spring_security_logout"><s:text name ="treelist.exit"></s:text></a></div>
  	</div>
  	<div class="navbox_out">
		<ul id="yuyunav"></ul>
  	</div>
</div>

